//定义任务，并将任务与相应的指令进行对应

#include<iostream>
#include<vector>
#include<string>
using  std::cout; 
using  std::endl; 
using  std::cin;

#include<unistd.h>

typedef void(*fun_t)();//定义函数指针


//定义任务函数
void PrintLog()
{
    cout<<"pid:"<<getpid()<<",正在执行打印日志任务！"<<endl;
}

void InsertMySQL()
{
    cout<<"pid:"<<getpid()<<",正在执行数据库任务！"<<endl;
}

void NetRequest()
{
    cout<<"pid:"<<getpid()<<",正在执行执行网络请求任务！"<<endl;
}

//约定，每一个command都必须是4字节
#define COMMAND_LOG 0
#define COMMAND_MYSQL 1
#define COMMAND_REQUEST 2


class Task
{
public:
    Task()
    {
        funcs.push_back(PrintLog);
        funcs.push_back(InsertMySQL);
        funcs.push_back(NetRequest);
    }

    void Execute(int command)
    {
        if(command>=0&&command<funcs.size())funcs[command]();
    }
private:
    std::vector<fun_t> funcs;
};

